/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sentry;

import io.sentry.protocol.Contexts;
import io.sentry.protocol.Request;
import io.sentry.protocol.SentryId;

import java.util.Collections;
import java.util.List;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * NoOpTransaction
 *
 * @since 2021-06-02
 **/
public final class NoOpTransaction implements ITransaction {
    private static final NoOpTransaction INSTANCE = new NoOpTransaction();

    private NoOpTransaction() {
    }

    public static NoOpTransaction getInstance() {
        return INSTANCE;
    }

    @Override
    public void setName(@NotNull String name) {
    }

    @Override
    public @NotNull String getName() {
        return "";
    }

    @Override
    public @NotNull ISpan startChild(final @NotNull String operation) {
        return NoOpSpan.getInstance();
    }

    @Override
    public @NotNull ISpan startChild(
        final @NotNull String operation, final @Nullable String description) {
        return NoOpSpan.getInstance();
    }

    /**
     * setRequest
     *
     * @param request the request
     * @deprecated use {@link Scope#setRequest(Request)}
     */
    @Override
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    public void setRequest(@Nullable Request request) {
    }

    /**
     * getRequest
     *
     * @return Request
     * @deprecated use {@link Scope#getRequest()}
     */
    @Override
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    public @Nullable Request getRequest() {
        return null;
    }

    /**
     * getContexts
     *
     * @return Contexts
     * @deprecated use {@link Scope#getContexts()}
     */
    @Override
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    public @NotNull Contexts getContexts() {
        return new Contexts();
    }

    @Override
    public @Nullable String getDescription() {
        return null;
    }

    @Override
    public @NotNull List<Span> getSpans() {
        return Collections.emptyList();
    }

    @Override
    public @Nullable Span getLatestActiveSpan() {
        return null;
    }

    @Override
    public @NotNull SentryId getEventId() {
        return SentryId.EMPTY_ID;
    }

    @Override
    public boolean isFinished() {
        return true;
    }

    @Override
    public @NotNull SentryTraceHeader toSentryTrace() {
        return new SentryTraceHeader(SentryId.EMPTY_ID, SpanId.EMPTY_ID, false);
    }

    @Override
    public void finish() {
    }

    @Override
    public void finish(@Nullable SpanStatus status) {
    }

    @Override
    public void setOperation(@NotNull String operation) {
    }

    @Override
    public @NotNull String getOperation() {
        return "";
    }

    @Override
    public void setDescription(@Nullable String description) {
    }

    @Override
    public void setStatus(@Nullable SpanStatus status) {
    }

    @Override
    public @Nullable SpanStatus getStatus() {
        return null;
    }

    @Override
    public void setThrowable(@Nullable Throwable throwable) {
    }

    @Override
    public @Nullable Throwable getThrowable() {
        return null;
    }

    @Override
    public @NotNull SpanContext getSpanContext() {
        return new SpanContext(SentryId.EMPTY_ID, SpanId.EMPTY_ID, "op", null, null);
    }

    @Override
    public void setTag(@NotNull String key, @NotNull String value) {
    }

    @Override
    public @Nullable String getTag(@NotNull String key) {
        return null;
    }

    @Override
    public @Nullable Boolean isSampled() {
        return null;
    }
}
